package org.jivesoftware.smackx.provider;

import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.provider.PacketExtensionProvider;
import org.jivesoftware.smackx.packet.MUCUser;
import org.jivesoftware.smackx.packet.MUCUser.Accept;
import org.jivesoftware.smackx.packet.MUCUser.Apply;
import org.jivesoftware.smackx.packet.MUCUser.Decline;
import org.jivesoftware.smackx.packet.MUCUser.Destroy;
import org.jivesoftware.smackx.packet.MUCUser.Invite;
import org.jivesoftware.smackx.packet.MUCUser.Item;
import org.jivesoftware.smackx.packet.MUCUser.MucType;
import org.jivesoftware.smackx.packet.MUCUser.Status;
import org.xmlpull.v1.XmlPullParser;

public class MUCUserProvider
  implements PacketExtensionProvider
{
  public PacketExtension parseExtension(XmlPullParser paramXmlPullParser)
    throws Exception
  {
    MUCUser localMUCUser = new MUCUser();
    int i = 0;
    while (i == 0)
    {
      int j = paramXmlPullParser.next();
      if (j == 2)
      {
        if (paramXmlPullParser.getName().equals("invite"))
          localMUCUser.setInvite(parseInvite(paramXmlPullParser));
        if (paramXmlPullParser.getName().equals("apply"))
          localMUCUser.setApply(parseApply(paramXmlPullParser));
        if (paramXmlPullParser.getName().equals("accept"))
          localMUCUser.setAccept(parseAccept(paramXmlPullParser));
        if (paramXmlPullParser.getName().equals("item"))
          localMUCUser.setItem(parseItem(paramXmlPullParser));
        if (paramXmlPullParser.getName().equals("password"))
          localMUCUser.setPassword(paramXmlPullParser.nextText());
        if (paramXmlPullParser.getName().equals("status"))
          localMUCUser.setStatus(new MUCUser.Status(paramXmlPullParser.getAttributeValue("", "code")));
        if (paramXmlPullParser.getName().equals("decline"))
          localMUCUser.setDecline(parseDecline(paramXmlPullParser));
        if (paramXmlPullParser.getName().equals("destroy"))
          localMUCUser.setDestroy(parseDestroy(paramXmlPullParser));
      }
      else if ((j == 3) && (paramXmlPullParser.getName().equals("x")))
      {
        i = 1;
      }
    }
    return localMUCUser;
  }

  private MUCUser.Item parseItem(XmlPullParser paramXmlPullParser)
    throws Exception
  {
    int i = 0;
    MUCUser.Item localItem = new MUCUser.Item(paramXmlPullParser.getAttributeValue("", "affiliation"), paramXmlPullParser.getAttributeValue("", "role"));
    localItem.setNick(paramXmlPullParser.getAttributeValue("", "nick"));
    localItem.setJid(paramXmlPullParser.getAttributeValue("", "jid"));
    while (i == 0)
    {
      int j = paramXmlPullParser.next();
      if (j == 2)
      {
        if (paramXmlPullParser.getName().equals("actor"))
          localItem.setActor(paramXmlPullParser.getAttributeValue("", "jid"));
        if (paramXmlPullParser.getName().equals("reason"))
          localItem.setReason(paramXmlPullParser.nextText());
      }
      else if ((j == 3) && (paramXmlPullParser.getName().equals("item")))
      {
        i = 1;
      }
    }
    return localItem;
  }

  private MUCUser.Invite parseInvite(XmlPullParser paramXmlPullParser)
    throws Exception
  {
    int i = 0;
    MUCUser.Invite localInvite = new MUCUser.Invite();
    localInvite.setFrom(paramXmlPullParser.getAttributeValue("", "from"));
    localInvite.setTo(paramXmlPullParser.getAttributeValue("", "to"));
    while (i == 0)
    {
      int j = paramXmlPullParser.next();
      if (j == 2)
      {
        if (paramXmlPullParser.getName().equals("reason"))
          localInvite.setReason(paramXmlPullParser.nextText());
      }
      else if ((j == 3) && (paramXmlPullParser.getName().equals("invite")))
        i = 1;
    }
    return localInvite;
  }

  private MUCUser.Apply parseApply(XmlPullParser paramXmlPullParser)
    throws Exception
  {
    int i = 0;
    MUCUser.Apply localApply = new MUCUser.Apply();
    localApply.setFrom(paramXmlPullParser.getAttributeValue("", "from"));
    localApply.setTo(paramXmlPullParser.getAttributeValue("", "to"));
    localApply.setToNick(paramXmlPullParser.getAttributeValue("", "toNick"));
    while (i == 0)
    {
      int j = paramXmlPullParser.next();
      if (j == 2)
      {
        if (paramXmlPullParser.getName().equals("reason"))
          localApply.setReason(paramXmlPullParser.nextText());
      }
      else if ((j == 3) && (paramXmlPullParser.getName().equals("apply")))
        i = 1;
    }
    return localApply;
  }

  private MUCUser.Accept parseAccept(XmlPullParser paramXmlPullParser)
    throws Exception
  {
    int i = 0;
    MUCUser.Accept localAccept = new MUCUser.Accept();
    localAccept.setFrom(paramXmlPullParser.getAttributeValue("", "from"));
    localAccept.setTo(paramXmlPullParser.getAttributeValue("", "to"));
    localAccept.setFromNick(paramXmlPullParser.getAttributeValue("", "fromNick"));
    while (i == 0)
    {
      int j = paramXmlPullParser.next();
      if (j == 2)
      {
        if (paramXmlPullParser.getName().equals("reason"))
          localAccept.setReason(paramXmlPullParser.nextText());
      }
      else if ((j == 3) && (paramXmlPullParser.getName().equals("accept")))
        i = 1;
    }
    return localAccept;
  }

  private MUCUser.Decline parseDecline(XmlPullParser paramXmlPullParser)
    throws Exception
  {
    int i = 0;
    MUCUser.Decline localDecline = new MUCUser.Decline();
    localDecline.setFrom(paramXmlPullParser.getAttributeValue("", "from"));
    localDecline.setTo(paramXmlPullParser.getAttributeValue("", "to"));
    localDecline.setFromNick(paramXmlPullParser.getAttributeValue("", "fromNick"));
    localDecline.setType(MUCUser.MucType.valueOf(paramXmlPullParser.getAttributeValue("", "type")));
    while (i == 0)
    {
      int j = paramXmlPullParser.next();
      if (j == 2)
      {
        if (paramXmlPullParser.getName().equals("reason"))
          localDecline.setReason(paramXmlPullParser.nextText());
      }
      else if ((j == 3) && (paramXmlPullParser.getName().equals("decline")))
        i = 1;
    }
    return localDecline;
  }

  private MUCUser.Destroy parseDestroy(XmlPullParser paramXmlPullParser)
    throws Exception
  {
    int i = 0;
    MUCUser.Destroy localDestroy = new MUCUser.Destroy();
    localDestroy.setJid(paramXmlPullParser.getAttributeValue("", "jid"));
    while (i == 0)
    {
      int j = paramXmlPullParser.next();
      if (j == 2)
      {
        if (paramXmlPullParser.getName().equals("reason"))
          localDestroy.setReason(paramXmlPullParser.nextText());
      }
      else if ((j == 3) && (paramXmlPullParser.getName().equals("destroy")))
        i = 1;
    }
    return localDestroy;
  }
}

/* Location:           D:\hygieia\userclient\common\libs\easemobchat_2.1.8.jar
 * Qualified Name:     org.jivesoftware.smackx.provider.MUCUserProvider
 * JD-Core Version:    0.6.1
 */